{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "deep-learning-basics.ipynb",
      "provenance": [],
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/towardsai/tutorials/blob/master/deep-learning/deep_learning_basics.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "DrdHQbwAvYcO"
      },
      "source": [
        "# Neuron Implementation\r\n",
        "\r\n",
        "* Tutorial: https://towardsai.net/deep-learning\r\n",
        "* Github: https://github.com/towardsai/tutorials/tree/master/deep-learning"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "29JF978gvSpE"
      },
      "source": [
        "import numpy as np"
      ],
      "execution_count": 1,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "c814KzCsvk8x"
      },
      "source": [
        "**Create Sigmoid function**"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "D_VDpun0vdJ1"
      },
      "source": [
        "def sigmoid(x):\r\n",
        "  return 1/ (1 + np.exp(-x))"
      ],
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "oDvAJGrlv-6_"
      },
      "source": [
        "# Creating an Artificial Neuron (AN)"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "EzX9ccMXvnjM"
      },
      "source": [
        "class Neuron:\r\n",
        "  def __init__(self, weights, bias):\r\n",
        "    self.weights = weights\r\n",
        "    self.bias = bias\r\n",
        "  \r\n",
        "  def feedforwards(self, inputs):\r\n",
        "    total = np.dot(self.weights, inputs) + self.bias\r\n",
        "    return sigmoid(total)\r\n"
      ],
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "DdAkVREWwBmT",
        "outputId": "1711b30b-c520-4965-9636-162ffd1814a8"
      },
      "source": [
        "weights = np.array([0, 1])\r\n",
        "bias = 4\r\n",
        "\r\n",
        "neuron = Neuron(weights, bias)\r\n",
        "\r\n",
        "x = np.array([2, 3])\r\n",
        "\r\n",
        "forward = neuron.feedforwards(x)\r\n",
        "\r\n",
        "print(forward)\r\n"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "0.9990889488055994\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}